import pygame
import sys

# 1.初始化
pygame.init()
print(pygame)
screen = pygame.display.set_mode(size=(800, 600))

# 7.标题
pygame.display.set_caption("pygame开发")
surface = pygame.surface.Surface((16, 16))
surface.fill("red")
pygame.display.set_icon(surface)

# 3.填充Surface Rect
bg_color = pygame.color.Color(125, 125, 125)
bg_rect = pygame.rect.Rect(0, 0, 800, 600)

# 5.创建一个面
center_sufarce = pygame.surface.Surface((400, 300))
center_color = pygame.color.Color(125, 0, 0)
center_rect = pygame.rect.Rect(0, 0, 400, 300)

# 9.绘制背景图
bg_surfarce = pygame.image.load("./bg.png.jpg")
pygame.draw.circle(bg_surfarce,(0,255,0),(750,50),50)

pos_y = -300
pos_x = -50
while True:
    # 3.事件处理

    for event in pygame.event.get():
        # 处理退出事件
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    pos_y += 1
    if pos_y == 600:
        pos_y = -300

    pos_x += 1
    if pos_x == 400:
        pos_x = -50

    # 填充屏幕
    screen.fill(bg_color, bg_rect)

    # 填充背景
    screen.blit(bg_surfarce,(0,0))

    # 填充矩形
    center_sufarce.fill(center_color, center_rect)

    # 6.将目标surface  显示到目标区域
    screen.blit(center_sufarce, (200, 600))

    # 4.更新绘制
    pygame.display.flip()

